<template>
<div class="announcement-management views-container">
  <div class="wlm-table">
    <div class="wlm-table-hearder-btn">
      <router-link tag="span" to="/operation/announcementManagementAdd">
        <el-button size="small" type="primary">添加公告</el-button>
      </router-link>
    </div>
    <div class="wlm-table-header">
      <el-form :model="tableFormatData.announcement.files" size="small" label-width="80px" class="retail-form" label-position="right">
        <el-form-item label="公告名称：" class="search">
          <el-input v-model="tableFormatData.announcement.files.title" placeholder="请输入公告名称" style="width:200px;"></el-input>
        </el-form-item>
        <el-form-item label="" class="filter-btns">
          <el-button type="primary" @click="filesSerch">筛选</el-button>
          <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="wlm-table-content">
      <el-table :ref="tableFormatData.announcement.key" :data="tableFormatData.announcement.tableData" @selection-change="handleSelectionChange" style="width: 100%">
        <el-table-column type="selection" width="55">
        </el-table-column>
        <el-table-column prop="date" label="公告名称" header-align="left" align="left">
          <template slot-scope="scope">
            <span>{{scope.row.title}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="date" label="作者" header-align="left" align="left">
          <template slot-scope="scope">
            <span>{{scope.row.author||'-'}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="添加时间" header-align="left" align="left">
          <template slot-scope="scope">
            <span>{{ scope.row.createtime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="状态" header-align="left" align="left">
          <template slot-scope="scope">
            <el-switch :active-value="1" :inactive-value="0" @change="changeTableItem({id:scope.row.id,is_show:scope.row.is_show},tableFormatData.announcement.change.is_show)" v-model="scope.row.is_show"> </el-switch>
          </template>
        </el-table-column>
        <el-table-column prop="address" label="操作" header-align="left" align="left">
          <template slot-scope="scope">
             <div class="operation-group">
                <router-link class="wlm-text" tag="span" :to="{path:'/operation/announcementManagementAdd', query:{id:scope.row.id}}">
                  <el-button type="text">编辑</el-button>
                </router-link>
                <div class="btn-line"></div>
                <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.id)">删除</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination-content flex-row flex-justify-b flex-align-c">
        <el-row class="pagination-btns">
          <el-checkbox class="check-all" :disabled="!hasTableData" true-label="1" false-label="0" v-model="tableFormatData.announcement.files.checkall" @change="toggleSelection">全部</el-checkbox>
          <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button>
        </el-row>
        <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.announcement.pagination.page" :page-sizes="tableFormatData.announcement.pagination.pagesizes" :page-size.sync="tableFormatData.announcement.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.announcement.pagination.total : 0">
        </el-pagination>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import {
  messageSetList,
  messageSetDel,
  messageSta
} from '@/api/setting'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table')],
  name: 'ManagementPlatform',
  components: {

  },
  data() {
    return {
      tableFormatData: {
        current: 'announcement',
        announcement: {
          key: 'announcement',
          api: {
            getList: messageSetList,
            delList: messageSetDel
          },
          tableData: [],
          files: {
            title: '',
            ids: [],
            checkall: '0',
            Recycle: '0'
          },
          change: {
            is_show: {
              name: '编辑',
              key: 'is_show',
              api: messageSta
            }
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      }
    }
  },
  methods: {

  }
}
</script>
